<!doctype html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
</head>
<body>
<!--header start -->
{include file="headerbanner"}
<!--header end-->


<table class="weui-table weui-border-tb" id="cusTable">
    <thead>
    <tr>
        <th  data-field="username" style="border-left:2px solid #fff">banner图</th>
        <th>banner描述</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {volist name="data" id="vo"}
        <tr>
            <th><img src="__UPLOADS__/{$vo.image}" style="height:45px;"></th>
            <th>{$vo.content}</th>
            <th><a href="####" onclick="change(this)" data-id="{$vo.id}" status="{$vo.status}"><span>{$vo.status == 1?'显示':'隐藏'}</span></a></th>
            <th>
                <a href="{:url('edit',['id'=>$vo.id])}" id="edit" data-id="{$vo.id}"><span class="icon icon-115" title="编辑">编辑</span></a>
                <a href="###"  data-id="{$vo.id}" onclick="del(this)" ><span class="icon icon-23"  title="删除">删除</span></a>
            </th>
        </tr>
    {/volist}

    </tbody>
</table>


<div class="pages">{$page}</div>
<!--footer start -->
{include file="footer"}
<!--footer end-->
<script>
    //修改状态
    function change(_this){
        var uid = $(_this).attr('data-id');
        var status = $(_this).attr('status');
        $.ajax({
            type:'post',
            url:"{:url('changeatatus')}",
            data:{'id':uid,'status':status},
            success:function(data){
                console.log(data)
                if(data.msg == '修改成功'){
                    if(data.statuid == 1){
                        $(_this).find('span').text('显示');
                        $(_this).attr('status',1);

                    }else{
                        $(_this).find('span').text('隐藏');
                        $(_this).attr('status',0);

                    }
                }
            }
        })
    }

    //删除
    function del(_this){
        var uid = $(_this).attr('data-id');
        $.ajax({
            type:'post',
            url:"{:url('delete')}",
            data:{'id':uid},
            success:function(data){

                switch(data){
                    case 1:
                        $(_this).parent().parent().remove();
                        break;
                    case 2:
                        alert('删除失败');
                        break;
                    case 3:
                        alert('用户不存在');
                        break;
                    case 4:
                        alert('请求格式不对');
                        break;
                }
            }
        })
    }
</script>
</body>
</html>